package com.qingshu.controller.custom;

import com.qingshu.common.annotation.Log;
import com.qingshu.common.entity.custom.Album;
import com.qingshu.common.entity.custom.MusicType;
import com.qingshu.common.enums.BusinessType;
import com.qingshu.common.util.body.JsonResult;
import com.qingshu.common.util.body.ResultTool;
import com.qingshu.common.util.model.ModelUtil;
import com.qingshu.service.IMusicTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Huzz
 * @since 2021-12-09
 */
@Api(tags = "歌曲类型管理")
@RestController
@RequestMapping("/custom/music-type")
public class MusicTypeController {

    @Autowired
    private IMusicTypeService musicTypeService;

    @Log(title = "歌曲类型业务-添加类型", businessType = BusinessType.INSERT, isSaveResponseParam = true)
    @ApiOperation(value = "添加类型")
    @PostMapping("/addMusicType")
    public JsonResult addMusicType(@RequestBody MusicType model){
        return musicTypeService.addMusicType((MusicType) ModelUtil.toEntityStatic(model, MusicType.class)) ? ResultTool.success() : ResultTool.fail();
    }

    @Log(title = "歌曲类型业务-查询全部", businessType = BusinessType.SELECT)
    @ApiOperation(value = "查询全部")
    @GetMapping("/findMusicTypeAll")
    public JsonResult findMusicTypeAll(){
        return ResultTool.success(musicTypeService.findMusicTypeAll());
    }

}
